#ifndef RPCVARIFYCODE_H
#define RPCVARIFYCODE_H
#include "../rpc/message.pb.h"
#include "../rpc/message.grpc.pb.h"
#include "SingleClass.h"
#include<grpc++/grpc++.h>
#include "conf_reader.h"
//创建一个类，用来发送获取验证码的rpc请求,并做成单例类
class userCenterRpc:public SingleClass<userCenterRpc>{
public:
    message::resGetVarify * get_varify_code(std::string &email);
    message::resGetVarify * get_varify_code(std::string &&email);

    message::resRegisterUser * registerUser(std::string & userName,std::string &email,std::string &passwd,std::string &authCode);
    message::resResetPasswd * reset_passwd(std::string &email,std::string &new_passwd,std::string &authCode);
    message::resLogin*login(std::string &email,std::string &passwd);
    
private:
   
    friend class SingleClass<userCenterRpc>;
    std::shared_ptr<grpc::Channel>_channel;
    std::unique_ptr< message::userCenter::Stub> _stub;

   

    userCenterRpc(){
        std::string info=conf_reader::get_conf_reader_instance()->get_value_from_key("rpcUserCenterIpPort","192.168.174.139:9999");
        std::cout<<"userCenterRpc的管道信息为："<<info<<std::endl;
        _channel=grpc::CreateChannel(info,grpc::InsecureChannelCredentials());
        _stub=message::userCenter::NewStub(_channel);   //通过channel创建存根时，在哪个类下创建就对应于对应的服务
    }

};

#endif